/*
 *@description: 容器
 *@author: zyc
 *@date-time: 2024-04-09 16:21:20
 */

import { Application, ApplicationOptions, Container as PixiContainer } from 'pixi.js'
export class Container extends Application {
  container: HTMLDivElement
  /**
   *
   */
  constructor(container: HTMLDivElement) {
    super()
    this.container = container
  }

  async init(options?: Partial<ApplicationOptions>) {
    await super.init(options)
    this.canvas.style.cssText = 'display:block'
    this.container.appendChild(this.canvas)
  }

  addChild<U extends PixiContainer>(children: U): U {
    this.stage.addChild(children)
    return children
  }

  removeChild<U extends PixiContainer>(children: U): U {
    this.stage.removeChild(children)
    return children
  }
}
